

/**
 * @Title: Create By MyEclipse 6.0
 * @Package: com.majj.tzx.marion.mjd.clutter.mipo.Ljd1.java
 * 
 * @author: marion
 * @Email: majinding888@163.com
 * @date: 2012-10-30 马晶晶 01:41:53
 * 
 * @memo:版本
 * 
 */

public class Ljd1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int ljd = 1234;
		String s = Integer.toHexString(ljd);
		System.out.println(s);
		
		String s2 = str2HexStr(String.valueOf(ljd));
		System.out.println(s2);
	}
	
	public static String str2HexStr(String str) {
		char[] chars = "0123456789ABCDEF".toCharArray();
		StringBuilder sb = new StringBuilder("");
		byte[] bs = str.getBytes();
		int bit;
		for (int i = 0; i < bs.length; i++) {
			bit = (bs[i] & 0x0f0) >> 4;
			sb.append(chars[bit]);
			bit = bs[i] & 0x0f;
			sb.append(chars[bit]);

		}
		return sb.toString();
	}

	
	public static String hexStr2Str(String hexStr) {
		String str = "0123456789ABCDEF";
		char[] hexs = hexStr.toCharArray();
		byte[] bytes = new byte[hexStr.length() / 2];
		int n;
		for (int i = 0; i < bytes.length; i++) {
			n = str.indexOf(hexs[2 * i]) * 16;
			n += str.indexOf(hexs[2 * i + 1]);
			bytes[i] = (byte) (n & 0xff);
		}
		return new String(bytes);
	}
	
	public static void ljd1() {
//		int ljd = 12345;
//		System.out.println(String.valueOf(ljd));
//		String ljdStr = String.valueOf(ljd);
//		String ljdUp = "";
//		char[] ljdCharArr = ljdStr.toCharArray();
//		for (int i = 0; i < ljdCharArr.length; i++) {
//			char c = ljdCharArr[i];
//			switch (c) {
//			case '0':
//				ljdUp += "零";
//				break;
//			case '1':
//				ljdUp += "一";
//				break;
//				//。。。省略
//			default:
//				ljdUp += c;
//				break;
//			}
//		}
//		System.out.println(ljdUp);
		
		
	}
}
